package com.kaishengit.pms.util;

import java.io.IOException;
import java.util.Properties;

import com.kaishengit.pms.dao.MessageDao;
import com.kaishengit.pms.entity.Message;

public class Util {
	private static Properties properties = new Properties();

	static {
		try {
			properties.load(Util.class.getClassLoader().getResourceAsStream(
					"mime.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static String getFileMIME(String path) {
		if (StringUtil.isEmpty(path)) {
			return null;
		}
		String ext = path.substring(path.lastIndexOf(".") + 1);
		return properties.getProperty(ext.trim());
	}

	public static Message sendMessage(String content, String projectid,
			String emid) {
	
		MessageDao mdao = new MessageDao();
		Message mes = new Message();
		mes.setCreatetime(DateUtil.getNow());
		mes.setId(PKUtil.getId());
		mes.setContent(content);
		mes.setProjectid(projectid);
		mes.setEmployeeid(emid);
		mdao.savemsg(mes);
		return mes;
	}
}
